{# src/Pyaf/GymBundle/Resources/views/Cuota/list.html.twig #}
{% extends "PyafGymBundle::layout_admin.html.twig" %}

{% block title %} Pyaf {% endblock %}
{% block tituloSector %}<i class=" icon-list-alt"></i> Alumnos - Listado de Alumnos y Cuotas  {% endblock %}
{% block nombreSector %} Alumnos / Cuota {% endblock %}
{% block dashboardContent %}{% endblock %}

{% block content %}
    <div class="container-fluid" id="content-area" style="padding-right: 30px;">    
        
        {% if app.session.hasFlash('alertaCuotaSuccess') %}
            <div class="alert alert-success">
                <button type="button" class="close" data-dismiss="alert">&times;</button>
                {{ app.session.flash('alertaCuotaSuccess') }}
            </div>
        {% endif %}
        {% if app.session.hasFlash('alertaCuotaError') %}
            <div class="alert alert-error">
                <button type="button" class="close" data-dismiss="alert">&times;</button>
                {{ app.session.flash('alertaCuotaError') }}
            </div>
        {% endif %}
        
    <div class="row-fluid">
        <div class="span12">
            <div class="box">
                <div class="box-head"><i class="icon-table"></i><span>Tablero de Alumnos</span></div>
                <div class="box-body">
                    
                    <div class="span6">
                        <div class="mini-layout">
                            <div class="mini-layout-header">
                                <i class="icon-th-large"></i>
                                <span>Alumnos</span>
                            </div>
                            <div class="mini-layout-body">  
                                <table id="table" class="table dataTable table-nomargin table-bordered  table-hover">
                                    <thead><tr>
                                            <th>Nombre y Apellido</th>                                                
                                            <th>Debe</th>
                                            <th>Listar cuotas</th>
                                            <th>Pagar</th>
                                    </tr></thead>
                                    <tbody>

                                    {% for alumno in alumnos %}

                                        <tr style="">
                                            <td><div id="alumno-{{alumno.id}}" style="position: relative; margin: 5px;" >
                                                {{ alumno.alumno.nombreCompleto }}
                                                </div>
                                            </td>
                                                {% if alumno.estado %}
                                                <td style="text-align: center;" class="control-group success">
                                                    <span style="position: relative; margin: 5px;" class="label label-success"> <i class="icon-bookmark-empty"> NO </i></span>
                                                </td>
                                                {% else %}
                                                <td style="text-align: center;" class="control-group error">
                                                    <span style="position: relative; margin: 5px;" class="label label-important"><i class="icon-bookmark-empty"> SI</i></span>
                                                </td>
                                                {% endif %}    
                                            <td style="text-align: center;">
                                                <button class='button button-basic btn-min button-basic-blue' onclick="loadCuotaAlumno('{{alumno.alumno.id}}')"><i class="icon-tasks"></i> ver</button>
                                            </td> 
                                            <td style="text-align: center;">
                                                {% if alumno.estado %}
                                                    <button class='button button-basic btn-min button-basic-blue disabled' readonly="true" disabled="true"><i class="icon-credit-card"></i> pagar</button>
                                                {% else %}
                                                    <button class='button button-basic btn-min button-basic-blue' onclick="loadCuotaPagoAlumno('{{alumno.alumno.id}}')"><i class="icon-credit-card"></i> pagar</button>
                                                {% endif %}
                                            </td> 
                                        </tr>

                                    {% endfor %}

                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                    <div class="span6">
                         <div class="mini-layout">
                            <div class="mini-layout-header">
                                <i class="icon-file-alt"></i>
                                <span>Detalle del Alumno</span>
                            </div>
                            <div class="mini-layout-body">
                                <div id="box-info-alumno"></div>  
                            </div>
                        </div>
                    </div>
                    <div class="span12"  style="padding-right: 60px;">
                         <div class="mini-layout">
                            <div class="mini-layout-header">
                                <i class="icon-file-alt"></i>
                                <span>Configurar aumento/disminución de cuotas</span>
                            </div>
                            <div class="mini-layout-body">
                                <div class="alert alert-info">
                                    <strong>Informativo!</strong> 
                                    Se propone el aumento o disminución de cuotas por medio de porcentajes, esta acción
                                    afectará a todos los usuarios, siendo indiferente el monto con que cuente cada uno!
                                </div>
                                
                                <form action="{{ path('cuotas_aumento') }}" method="post" class="text-center">
                                    <div class="input-append">
                                        <input class="text-right" type="number" id="aumentoCuota" name="aumentoCuota" placeholder="00" required="required">
                                        <span class="add-on">%</span>
                                    </div>
                                    <br />
                                    <input type="submit" value="Aplicar" class="btn btn-inverse" />
                                </form>     
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

{% endblock %}
  
{% block javascripts %}
    <script type="text/javascript">
                         
            function showCuotaAlumno(path, alumno){                
                $('#box-info-alumno').load(path, {id_alumno:alumno});             
            };
        
            function loadCuotaAlumno(idAlumno){
                showCuotaAlumno("{{ path('cuotas_show_pagos_alumno') }}", idAlumno);
            };                       
            
            function loadCuotaPagoAlumno(idAlumno){
                showCuotaAlumno("{{ path('cuotas_pagar') }}", idAlumno);                
            };
    </script>
{% endblock %}